<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改用户提现记录')" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-userwithdraw-edit" th:object="${whUserwithdraw}">
            <input name="id" th:field="*{id}" type="hidden">
            <label class="col-sm-3 control-label">转账凭证：</label>
            <div class="col-sm-8">
                <input type="hidden" name="payPic" th:field="*{payPic}">
                <div class="file-loading">
                    <input class="form-control file-upload" id="payPic" name="file" type="file">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <script th:inline="javascript">
        var prefix = ctx + "whzj/userwithdraw";
        $("#form-userwithdraw-edit").validate({
            focusCleanup: true
        });

        $(".file-upload").each(function (i) {
            var val = $("input[name='" + this.id + "']").val()
            $(this).fileinput({
                'uploadUrl': '/common/upload',
                initialPreviewAsData: true,
                initialPreview: [val],
                maxFileCount: 1,
                autoReplace: true
            }).on("filebatchselected", function(event, files) {
                $(this).fileinput("upload");
            })
                .on("fileuploaded", function(event, data) {
                    if(data.response)
                    {
                        $("input[name='" + event.currentTarget.id + "']").val(data.response.url);
                    }
                }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('')
            });
            $(this).fileinput('_initFileActions');
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-userwithdraw-edit').serialize());
            }
        }
    </script>
</body>
</html>